package com.h1909d.weinfo.ui.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.h1909d.weinfo.R;
import com.h1909d.weinfo.base.BaseLazyFragment;
import com.h1909d.weinfo.bean.HotBean;
import com.h1909d.weinfo.presenter.HotPresenter;
import com.h1909d.weinfo.ui.adapter.RlvHotAdapter;
import com.h1909d.weinfo.view.HotView;

import java.util.ArrayList;

public class HotFragment extends BaseLazyFragment<HotPresenter> implements HotView {

    private RecyclerView mRlv;
    private ArrayList<HotBean.RecentBean> recentBeans;
    private RlvHotAdapter rlvHotAdapter;

    /**
     *
     * @return
     */
    public static HotFragment getInstance(){
        HotFragment fragment = new HotFragment();
        return fragment;
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mPresenter.getLastHot();
    }

    @Override
    protected HotPresenter initPresenter() {
        return new HotPresenter();
    }

    @Override
    protected void initView(View view) {
        mRlv = view.findViewById(R.id.rlv);

        recentBeans = new ArrayList<>();
        rlvHotAdapter = new RlvHotAdapter(getActivity(), recentBeans);
        mRlv.setAdapter(rlvHotAdapter);
        mRlv.setLayoutManager(new LinearLayoutManager(getActivity()));
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_hot;
    }

    @Override
    public void setData(HotBean hotBean) {
        rlvHotAdapter.setData(hotBean);
    }
}
